
*******COLUMN ONE*******
qui{
use "$jfqa_rep/20_Stock_Setup.dta", clear

drop if missing(convexity_split)
drop if missing(futret)

drop if year<1963
drop if year==1963 & month<6

drop if year>2022
drop if year==2022 & month==12

*set panel
tsset permno monthyear
sort monthyear permno
replace futret=futret*100

rename ret_11_month mom_ret

drop if missing(bm_ratio) | missing(profit) | missing(asset) | missing(mom_ret) | missing(ret)
drop if missing(max_ret) | missing(iv_ff3) | missing(skew) | missing(illiquid) | missing(ret_1)

winsor2 convexity_split, cuts(1 99) by(monthyear)
winsor2 mktcap, cuts(1 99) by(monthyear)
winsor2 bm_ratio, cuts(1 99) by(monthyear)
winsor2 profit, cuts(1 99) by(monthyear)
winsor2 asset, cuts(1 99) by(monthyear)
winsor2 mom_ret, cuts(1 99) by(monthyear)
winsor2 ret, cuts(1 99) by(monthyear)
winsor2 iv_ff3, cuts(1 99) by(monthyear)
winsor2 illiquid, cuts(1 99) by(monthyear)
winsor2 skew, cuts(1 99) by(monthyear)
winsor2 max_ret, cuts(1 99) by(monthyear)
winsor2 ret_1, cuts(1 99) by(monthyear)

*log variables
gen log_mktcap=log(mktcap_w)
gen log_bm=log(bm_ratio_w)

*gen standard variables
egen convex_std=std(convexity_split_w) 
egen mktcap_std=std(log_mktcap) 
egen bm_std=std(log_bm) 
egen profit_std=std(profit_w)
egen asset_std=std(asset_w)
egen mom_std=std(mom_ret_w)
egen ret_std=std(ret_w)
egen iv_ff3_std=std(iv_ff3_w)
egen illiquid_std=std(illiquid_w)
egen skew_std=std(skew_w)
egen max_std=std(max_ret_w)
egen ret_1_std=std(ret_1_w)

egen month_mktcap=sum(mktcap), by(monthyear)
gen mktcap_scale=mktcap/month_mktcap

qui{
keep monthyear futret convex_std ret_1_std mktcap_std bm_std profit_std asset_std mom_std ret_std illiquid_std iv_ff3_std skew_std max_std mktcap_scale

est clear 
statsby _b e(r2), by(monthyear) saving("$jfqa_rep/Table_6B_1", replace): reg futret convex_std ret_1_std mktcap_std bm_std profit_std asset_std mom_std ret_std iv_ff3_std illiquid_std skew_std max_std [aweight=mktcap_scale]
}
}

use "$jfqa_rep/Table_6B_1", clear
tsset monthyear
newey _b_convex_std, lag(6)
newey _b_ret_1_std, lag(6)
sum _eq2_stat_1

*******COLUMN TWO*******
qui{
use "$jfqa_rep/20_Stock_Setup.dta", clear

drop if missing(convexity_split)
drop if missing(futret)

drop if year<1963
drop if year==1963 & month<6

drop if year>2022
drop if year==2022 & month==12

*set panel
tsset permno monthyear
sort monthyear permno
replace futret=futret*100

rename ret_11_month mom_ret

drop if missing(bm_ratio) | missing(profit) | missing(asset) | missing(mom_ret) | missing(ret)
drop if missing(max_ret) | missing(iv_ff3) | missing(skew) | missing(illiquid) | missing(ret_1)

winsor2 convexity_split, cuts(1 99) by(monthyear)
winsor2 bm_ratio, cuts(1 99) by(monthyear)
winsor2 profit, cuts(1 99) by(monthyear)
winsor2 asset, cuts(1 99) by(monthyear)
winsor2 mom_ret, cuts(1 99) by(monthyear)
winsor2 ret, cuts(1 99) by(monthyear)
winsor2 iv_ff3, cuts(1 99) by(monthyear)
winsor2 illiquid, cuts(1 99) by(monthyear)
winsor2 skew, cuts(1 99) by(monthyear)
winsor2 max_ret, cuts(1 99) by(monthyear)
winsor2 ret_5, cuts(1 99) by(monthyear)

*log variables
gen log_mktcap=log(mktcap)
gen log_bm=log(bm_ratio_w)

*gen standard variables
egen convex_std=std(convexity_split_w) 
egen mktcap_std=std(log_mktcap) 
egen bm_std=std(log_bm) 
egen profit_std=std(profit_w)
egen asset_std=std(asset_w)
egen mom_std=std(mom_ret_w)
egen ret_std=std(ret_w)
egen iv_ff3_std=std(iv_ff3_w)
egen illiquid_std=std(illiquid_w)
egen skew_std=std(skew_w)
egen max_std=std(max_ret_w)
egen ret_5_std=std(ret_5_w)

egen month_mktcap=sum(mktcap), by(monthyear)
gen mktcap_scale=mktcap/month_mktcap

qui{
keep monthyear futret convex_std ret_5_std mktcap_std bm_std profit_std asset_std mom_std ret_std illiquid_std iv_ff3_std skew_std max_std mktcap_scale

est clear 
statsby _b e(r2), by(monthyear) saving("$jfqa_rep/Table_6B_2", replace): reg futret convex_std ret_5_std mktcap_std bm_std profit_std asset_std mom_std ret_std iv_ff3_std illiquid_std skew_std max_std [aweight=mktcap_scale]
}
}

use "$jfqa_rep/Table_6B_2", clear
tsset monthyear
newey _b_convex_std, lag(6)
newey _b_ret_5_std, lag(6)
sum _eq2_stat_1

*******COLUMN THREE*******
qui{
use "$jfqa_rep/20_Stock_Setup.dta", clear

drop if missing(convexity_split)
drop if missing(futret)

drop if year<1963
drop if year==1963 & month<6

drop if year>2022
drop if year==2022 & month==12

*set panel
tsset permno monthyear
sort monthyear permno
replace futret=futret*100

rename ret_11_month mom_ret

drop if missing(bm_ratio) | missing(profit) | missing(asset) | missing(mom_ret) | missing(ret)
drop if missing(max_ret) | missing(iv_ff3) | missing(skew) | missing(illiquid) | missing(ret_10)

winsor2 convexity_split, cuts(1 99) by(monthyear)
winsor2 mktcap, cuts(1 99) by(monthyear)
winsor2 bm_ratio, cuts(1 99) by(monthyear)
winsor2 profit, cuts(1 99) by(monthyear)
winsor2 asset, cuts(1 99) by(monthyear)
winsor2 mom_ret, cuts(1 99) by(monthyear)
winsor2 ret, cuts(1 99) by(monthyear)
winsor2 iv_ff3, cuts(1 99) by(monthyear)
winsor2 illiquid, cuts(1 99) by(monthyear)
winsor2 skew, cuts(1 99) by(monthyear)
winsor2 max_ret, cuts(1 99) by(monthyear)
winsor2 ret_10, cuts(1 99) by(monthyear)

*log variables
gen log_mktcap=log(mktcap_w)
gen log_bm=log(bm_ratio_w)

*gen standard variables
egen convex_std=std(convexity_split_w) 
egen mktcap_std=std(log_mktcap) 
egen bm_std=std(log_bm) 
egen profit_std=std(profit_w)
egen asset_std=std(asset_w)
egen mom_std=std(mom_ret_w)
egen ret_std=std(ret_w)
egen iv_ff3_std=std(iv_ff3_w)
egen illiquid_std=std(illiquid_w)
egen skew_std=std(skew_w)
egen max_std=std(max_ret_w)
egen ret_10_std=std(ret_10_w)

egen month_mktcap=sum(mktcap), by(monthyear)
gen mktcap_scale=mktcap/month_mktcap

qui{
keep monthyear futret convex_std ret_10_std mktcap_std bm_std profit_std asset_std mom_std ret_std illiquid_std iv_ff3_std skew_std max_std mktcap_scale

est clear 
statsby _b e(r2), by(monthyear) saving("$jfqa_rep/Table_6B_3", replace): reg futret convex_std ret_10_std mktcap_std bm_std profit_std asset_std mom_std ret_std iv_ff3_std illiquid_std skew_std max_std [aweight=mktcap_scale]
}
}

use "$jfqa_rep/Table_6B_3", clear
tsset monthyear
newey _b_convex_std, lag(6)
newey _b_ret_10_std, lag(6)
sum _eq2_stat_1
